<?php

namespace app\company\validate;


class WarehouseTakeStockValidate extends BaseValidate
{
    public function __construct()
    {
        $rule = [
            'warehouse_id'  => 'require|integer|gt:0',
            'type'          => 'require|integer|in:1,2',
            'start_time'    => 'require|date',
            'goods_cate_id' => 'requireIf:type,2|integer|gt:0',
        ];

        $message = [
            'warehouse_id.require'    => '仓库id必须',
            'warehouse_id.integer'    => '仓库id必须为整数',
            'warehouse_id.gt'         => '仓库id必须大于0',
            'type.require'            => '盘点类型必须',
            'type.integer'            => '盘点类型必须为整数',
            'type.in'                 => '盘点类型必须为1或2',
            'start_time.require'      => '盘点开始时间必须',
            'start_time.date'         => '盘点开始时间必须为日期格式',
            'goods_cate_id.requireIf' => '商品分类id必须',
            'goods_cate_id.integer'   => '商品分类id必须为整数',
            'goods_cate_id.gt'        => '商品分类id必须大于0',
        ];

        $scene = [
            'add' => ['warehouse_id', 'type','goods_cate_id'],
        ];
        parent::__construct($rule, $message, $scene);
    }
}